(function($) {

	"use strict";


    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
	// ��������
	$("#txtScenic" ).autocomplete({
		   minLength: 0,
           source: function( request, response ) {
               $.ajax({
	       			url : "/index/scenicThinkData",
	       			type : "post",
	       			dataType : "json",
	       			data : {"scenicName":$("#txtScenic").val()},
	       			
                   success: function( data ) {
	                     console.log(data);
	                     response( $.map( data, function( item ) {
		                       return {
		                    	   label: item,
			                       value: item
		                       }
	                     }));
                   }
              });
           },
           focus: function( event, ui ) {
        	   $("#txtScenic").val( ui.item.value );
                 return false;
               },
           select: function( event, ui ) {
        	   $("#txtScenic").val( ui.item.value );
               return false;
           }
    });

	$("#btn_search").click(function() {
		var search_v = $("#txtScenic").val();
		if($.trim(search_v).length == 0) {return;}
		$.ajax({
   			url : "/index/scenicPreciseData",
   			type : "post",
   			dataType : "json",
   			data : {"scenicName":$("#txtScenic").val()},
   			
           success: function( data ) {
                 console.log(data);
                 if(data == 1) {
                	 // 如果只有一条，则进入详情页面
                	 window.location.href="/scenicInfo/"+search_v;
                 }
           }
      });
		
		
	});
	


})(jQuery);
